package uz.rt.linac;

import uz.rt.units.Angle;
import uz.rt.utils.Coordinate;


public class Linac
{
// ------------------------------ FIELDS ------------------------------
    protected double energy;
    protected Coordinate<Double> tablePosition = null;
    private int id;
    private String name;

    private Collimator collimator;
    private Angle gantry;
    private Angle table;
    private Vendor vendor;
    private Wedge wedge = null;
    private Tray tray = null;
    private boolean wedgePresent = false;
    private boolean trayPresent = false;

// --------------------------- CONSTRUCTORS ---------------------------

    public Linac(int id)
    {
        this.id = id;
        tablePosition = new Coordinate<Double>(3, 0.0);
    }

    public Linac(int id, String name)
    {
        this.id = id;
        this.name = name;
        tablePosition = new Coordinate<Double>(3, 0.0);
    }

// --------------------- GETTER / SETTER METHODS ---------------------

    public Collimator getCollimator()
    {
        return collimator;
    }

    public void setCollimator(Collimator collimator)
    {
        this.collimator = collimator;
    }

    public double getEnergy()
    {
        return energy;
    }

    public void setEnergy(double energy)
    {
        this.energy = energy;
    }

    public Angle getGantry()
    {
        return gantry;
    }

    public void setGantry(Angle gantry)
    {
        this.gantry = gantry;
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public Angle getTable()
    {
        return table;
    }

    public void setTable(Angle table)
    {
        this.table = table;
    }

    public Coordinate<Double> getTablePosition()
    {
        return tablePosition;
    }

    public void setTablePosition(Coordinate<Double> tablePosition)
    {
        this.tablePosition = tablePosition;
    }

    public Tray getTray()
    {
        return tray;
    }

    public Vendor getVendor()
    {
        return vendor;
    }

    public Wedge getWedge()
    {
        return wedge;
    }

    public boolean isTrayPresent()
    {
        return trayPresent;
    }

    public void setTrayPresent(boolean trayPresent)
    {
        this.trayPresent = trayPresent;
    }

    public boolean isWedgePresent()
    {
        return wedgePresent;
    }

    public void setWedgePresent(boolean wedgePresent)
    {
        this.wedgePresent = wedgePresent;
    }

// -------------------------- OTHER METHODS --------------------------

    public void setTray(Tray tray)
    {
        if (isTrayPresent())
            this.tray = tray;
    }

    public void setVendor(Vendor vendor)
    {
        if (vendor == Vendor.Elekta || vendor == Vendor.Varian || vendor == Vendor.Siemens)
            this.vendor = vendor;
        else
            throw new RuntimeException("Trying to set unknown linac Vendor");
    }

    public void setWedge(Wedge wedge)
    {
        if (isWedgePresent())
            this.wedge = wedge;
    }
}
